﻿<%@ Page Language="C#" MasterPageFile="~/WebSite.Master" AutoEventWireup="true" CodeBehind="EnterpriseMachineinfo.aspx.cs"
    Inherits="RN.ERP.Web.Enterprise.EnterpriseMachineinfo" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <link href="../Styles/skins/blue/css/style.css" rel="stylesheet" type="text/css" />
    <link href="../Styles/skins/blue/css/style_msg.css" rel="stylesheet" type="text/css" />
    <link rel="Stylesheet" type="text/css" href="../Scripts/ligerUI/skins/Aqua/css/ligerui-all.css" />
    <link href="../Styles/skins/blue/css/kendo.common.min.css" rel="stylesheet" />
    <link href="../Styles/skins/blue/css/kendo.default.min.css" rel="stylesheet" />
    <script type="text/javascript" src="../Scripts/jquery.min.js"></script>
    <script type="text/javascript" src="../Scripts/ligerUI/js/ligerui.min.js"></script>
    <script src="../Scripts/json-data.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(function () {

            $("#btnRet").click(function () {
                window.location = "EnterpriseMachineInfoList.aspx";
            });

            var macGuid = $("#ContentPlaceHolder1_hdMacGuid").val();
            var status = $("#ContentPlaceHolder1_hdStatus").val(); //0表示新增，1表示查看，2表示修改
            var id = $("#ContentPlaceHolder1_hdID").val();
            var datas = {};

            

            //查看数据，所有都为只读
            if (status == "1") {
                ImgShow1();
                datas.action = "getMachineInfo";
                datas.mid = id;
                datas.rand = Math.random();
                $.getJSON("../Handlers/EnterpriseCorpInfoHandler.ashx", datas, function (data) {
                    if (data.Result) {
                        SetControlVal("machineInfo", data.ReturnValue); //页面控件赋值
                    }
                    $("#machineInfo input").attr("disabled", "disabled");
                    $("#ContentPlaceHolder1_DropIsOwn").attr("disabled", "disabled");
                    $("#<%=btnSaveDiv.ClientID %>").css("visibility", "hidden");
                    $("#ContentPlaceHolder1_certImgDiv").css("visibility", "hidden");
                });
            }

            //修改数据
            if (status == "2") {
                ImgShow1();
                datas.action = "getMachineInfo";
                datas.mid = id;
                datas.rand = Math.random();
                $.getJSON("../Handlers/EnterpriseCorpInfoHandler.ashx", datas, function (data) {
                    if (data.Result) {
                        SetControlVal("machineInfo", data.ReturnValue); //页面控件赋值
                    }
                });
            }


            //上传发票扫描件
            $("#certImgUpload").click(function () {
                if ($("#ContentPlaceHolder1_txtMachineName").val() == "") {
                    OpenAlert("请先填写设备名称！");
                    return false;
                }
                if ($("#ContentPlaceHolder1_txtProductionPlace").val() == "") {
                    OpenAlert("请先填写产地！");
                    return false;
                }
                if ($("#ContentPlaceHolder1_txtModelNumber").val() == "") {
                    OpenAlert("请先填写型号！");
                    return false;
                }
                if ($("#ContentPlaceHolder1_txtQuantity").val() == "") {
                    OpenAlert("请先填写数量！");
                    return false;
                }
                if ($("#ContentPlaceHolder1_DropIsOwn").val() == "") {
                    OpenAlert("请先选择自由或租赁！");
                    return false;
                }
                var title = "上传机械设备发票扫描件";
                $.ligerDialog.open({ url: "../UserControl/FileUploadList.aspx?title=" + escape(title) + "&filename=" + macGuid + " &FuncCode=MacInvoice", width: 650, height: 570, title: '' });
                return false;
            });

            //保存基本信息
            $("#SaveMachineInfo").click(function () {
                var btnId = "SaveMachineInfo";
                var dataValid = CheckControlValid(btnId);
                if (!dataValid) {
                    return false;
                }
                var pageData = {};
                var dataStr = GetData(btnId); //取得页面上的所有数据
                pageData.data = dataStr;
                pageData.rand = Math.random();

                //提交
                $("#" + btnId).attr("disabled", "disabled");
                if (status == "0") {
                    pageData.action = "MachineInfoAdd";
                    MachineInfoAdd(pageData, btnId);
                } else if (status == "2") {
                    pageData.action = "MachineInfoEdit";
                    MachineInfoEdit(pageData, btnId);
                }
                //window.location = "EnterpriseMachineinfo.aspx";
            });

            /*添加设备基本信息*/
            function MachineInfoAdd(pageData, btnId) {
                $.getJSON("../Handlers/EnterpriseCorpInfoHandler.ashx", pageData, function (data) {
                    $("#" + btnId).removeAttr("disabled");
                    if (data.Result) {
                        status = 1;
                    }
                    alert(data.Message);
                });
            }

            /*修改设备基本信息*/
            function MachineInfoEdit(pageData, btnId) {
                $.getJSON("../Handlers/EnterpriseCorpInfoHandler.ashx", pageData, function (data) {
                    $("#" + btnId).removeAttr("disabled");
                    if (data.Result) {
                        status = 1;
                    }
                    alert(data.Message);
                });
            }
          
            $("#certimg").click(function () {
                var title = "查看机械设备发票扫描件";
                $.ligerDialog.open({ url: "../Enterprise/UploadFileShowList.aspx?title=" + escape(title) + "&fileName=" + macGuid + "&fileType=.jpg&sysCode=EF&funcCode=MacInvoice",
                    width: 760, height: 650, title: '', isResize: true,
                    buttons: [{ text: '关闭', onclick: function (item, dialog) { dialog.close(); } }]
                });
                return false;
            });
        });

        //加载扫描件
        function ImgShow1() {
            var macGuid = $("#ContentPlaceHolder1_hdMacGuid").val();
            $("#certimg").attr("src", "../Handlers/GetFileHandler.ashx?fileName=" + macGuid + ".jpg&sysCode=EF&funcCode=MacInvoice&rand=" + Math.random());
            $("#certimg").show();
        }
        /*关闭窗口*/
        function OnClientCloseImg(args) {
            var arg = args;
            if (arg) {
                if (arg.Result == 1) {
                    return;
                }
                ImgShow1();
            }
        }
        function returnToParent() {
            window.parent.$.ligerDialog.close(); ////关闭dialog
            parent.$(".l-dialog,.l-window-mask").hide(); ////去除父窗体遮罩层
        }

        /*打开添加扫描件窗口*/
        function ShowUpForm(u, w, h, win) {
            win = win || this;
            $.ligerDialog.open({ url: u, width: w, height: h, title: '', buttons: [{ text: '关闭', onclick: function (item, dialog) { dialog.close(); } }] });
            win.ChildDialogWin = this;
            return false;
        }
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <table width="100%" border="0" cellspacing="0" cellpadding="0" align="left" style="table-layout: fixed;">
        <tr>
            <td class="xx_m  tt_xx_l">
            </td>
            <td class="xx_m  tt_xx_icon">
            </td>
            <td style="width: auto;" class="xx_m">
                设备信息
            </td>
            <td style="width: 14px;">
                <img src="../images/xx_r.jpg" width="14" height="33" />
            </td>
        </tr>
        <tr>
            <td class="left_con">
                &nbsp;
            </td>
            <td colspan="2" style="padding-left: 6px; padding-top: 2px; padding-right: 6px;"
                valign="top">
                <!--#企业自有或租赁的主要机械设备-->
                <div id="machineInfo" table="tb_corp_machineinfo" valtype="0">
                    <table width="100%" border="0" cellspacing="0" cellpadding="0">
                        <tr>
                            <td colspan="2">
                                <div class="xian">
                                    <div class="about_title">
                                        企业自有或租赁的主要机械设备
                                        <input id="hdMacGuid" type="hidden" runat="server" value="" control="MacGuid" />
                                    </div>
                                    <div class="i-con-cn">
                                        <a href="javascript:void(0);" id="btnRet" class="xtbiao">返回列表</a>
                                    </div>
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <table width="750px" border="0" cellspacing="0" cellpadding="0" class="xx_tab" style="margin: 0 auto;">
                                    <tr>
                                        <td width="200" align="right">
                                            设备及仪器名称
                                        </td>
                                        <td>
                                            <div class="s_input">
                                                <span class="input_l">
                                                    <img src="../images/input_l.jpg" width="10" height="31" alt="" /></span> <span class="input_mm">
                                                        <input id="txtMachineName" runat="server" name="text" maxlength="50" type="text"
                                                            value="" style="width: 205px; height: 31px; line-height: 31px; border: 0; background: transparent"
                                                            control="MachineName" controlvalid="checkEmpty(this,'');" controltext="设备及仪器名称" /></span>
                                                <span class="input_r">
                                                    <img src="../images/input_r.jpg" width="10" height="31" alt="" /></span>
                                            </div>
                                        </td>
                                        <td align="right">
                                            型号
                                        </td>
                                        <td>
                                            <div class="s_input">
                                                <span class="input_l">
                                                    <img src="../images/input_l.jpg" width="10" height="31" alt="" /></span> <span class="input_mm">
                                                        <input id="txtModelNumber" runat="server" name="text" maxlength="50" type="text"
                                                            value="" style="width: 205px; height: 31px; line-height: 31px; border: 0; background: transparent"
                                                            control="ModelNumber" controlvalid="checkEmpty(this,'');" controltext="型号" /></span>
                                                <span class="input_r">
                                                    <img src="../images/input_r.jpg" width="10" height="31" alt="" /></span>
                                            </div>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td align="right">
                                            产地
                                        </td>
                                        <td>
                                            <div class="s_input">
                                                <span class="input_l">
                                                    <img src="../images/input_l.jpg" width="10" height="31" alt="" /></span> <span class="input_mm">
                                                        <input id="txtProductionPlace" runat="server" name="text" maxlength="50" type="text"
                                                            value="" style="width: 205px; height: 31px; line-height: 31px; border: 0; background: transparent"
                                                            control="ProductionPlace" controlvalid="checkEmpty(this,'');" controltext="产地" /></span>
                                                <span class="input_r">
                                                    <img src="../images/input_r.jpg" width="10" height="31" alt="" /></span>
                                            </div>
                                        </td>
                                        <td width="186" align="right">
                                            出厂日期
                                        </td>
                                        <td width="375">
                                            <div class="s_input">
                                                <span class="input_l">
                                                    <img src="../images/input_l.jpg" width="10" height="31" alt="" /></span> <span class="input_mm">
                                                        <input id="txtReleaseDate" name="text" type="text" value="" maxlength="10" style="width: 205px;
                                                            height: 31px; line-height: 31px; border: 0; background: transparent" control="ReleaseDate"
                                                            readonly="readonly" onclick="WdatePicker({skin:'blue',maxDate:'%y-%M-%d'})" controlvalid="checkEmpty(this,'');"
                                                            controltext="出厂日期" />
                                                    </span><span class="input_r">
                                                        <img src="../images/input_r.jpg" width="10" height="31" alt="" /></span>
                                            </div>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td align="right">
                                            数量(台)
                                        </td>
                                        <td>
                                            <div class="s_input">
                                                <span class="input_l">
                                                    <img src="../images/input_l.jpg" width="10" height="31" alt="" /></span> <span class="input_mm">
                                                        <input id="txtQuantity" runat="server" name="text" maxlength="50" type="text" value=""
                                                            style="width: 205px; height: 31px; line-height: 31px; border: 0; background: transparent"
                                                            control="Quantity" controlvalid="checkEmpty(this,'');" controltext="数量(台)" /></span>
                                                <span class="input_r">
                                                    <img src="../images/input_r.jpg" width="10" height="31" alt="" /></span>
                                            </div>
                                        </td>
                                        <td align="right">
                                            功率(千瓦)
                                        </td>
                                        <td>
                                            <div class="s_input">
                                                <span class="input_l">
                                                    <img src="../images/input_l.jpg" width="10" height="31" alt="" /></span> <span class="input_mm">
                                                        <input id="txtPower" runat="server" name="text" maxlength="50" type="text" value=""
                                                            style="width: 205px; height: 31px; line-height: 31px; border: 0; background: transparent"
                                                            control="Power" controlvalid="checkEmpty(this,'');" controltext="功率(千瓦)" /></span>
                                                <span class="input_r">
                                                    <img src="../images/input_r.jpg" width="10" height="31" alt="" /></span>
                                            </div>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td align="right">
                                            原值(万元)
                                        </td>
                                        <td>
                                            <div class="s_input">
                                                <span class="input_l">
                                                    <img src="../images/input_l.jpg" width="10" height="31" alt="" /></span> <span class="input_mm">
                                                        <input id="txtOriginalValue" runat="server" name="text" type="text" value="" maxlength="50"
                                                            style="width: 205px; height: 31px; line-height: 31px; border: 0; background: transparent"
                                                            control="OriginalValue" controlvalid="checkEmpty(this,'');" controltext="原值(万元)" /></span>
                                                <span class="input_r">
                                                    <img src="../images/input_r.jpg" width="10" height="31" alt="" /></span>
                                            </div>
                                        </td>
                                        <td align="right">
                                            净值(万元)
                                        </td>
                                        <td>
                                            <div class="s_input">
                                                <span class="input_l">
                                                    <img src="../images/input_l.jpg" width="10" height="31" alt="" /></span> <span class="input_mm">
                                                        <input id="txtNetValue" runat="server" name="text" type="text" maxlength="50" value=""
                                                            style="width: 205px; height: 31px; line-height: 31px; border: 0; background: transparent"
                                                            control="NetValue" controlvalid="checkEmpty(this,'');" controltext="净值(万元)" /></span>
                                                <span class="input_r">
                                                    <img src="../images/input_r.jpg" width="10" height="31" alt="" /></span>
                                            </div>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td align="right">
                                            自有或租赁
                                        </td>
                                        <td colspan="3">
                                            <div class="s_input">
                                                <span class="input_l">
                                                    <img src="../images/input_l.jpg" width="10" height="31" alt="" /></span> <span class="input_mm">
                                                        <select id="DropIsOwn" runat="server" style="width: 205px; height: 20px; line-height: 31px;
                                                            margin-top: 5px; border: 0;" control="IsOwn" controlvalid="SelEmpty(this,'-1')"
                                                            controltext="自有或租赁">
                                                        </select></span> <span class="input_r">
                                                            <img src="../images/input_r.jpg" width="10" height="31" alt="" /></span>
                                            </div>
                                            <input id="txtID" runat="server" name="text" maxlength="50" type="text" value=""
                                                style="width: 205px; height: 31px; line-height: 31px; border: 0; background: transparent;
                                                display: none;" control="ID" />
                                        </td>
                                    </tr>
                                    <tr>
                                        <td width="67" align="right" valign="top">
                                            上传机械设备发票扫描件
                                        </td>
                                        <td align="left" colspan="3">
                                            <div runat="server" id="certImgDiv">
                                                <a href="javascript:void(0);" id="certImgUpload">
                                                    <img alt="上传" src="../images/btn.jpg" /></a>
                                            </div>
                                            <div>
                                                <img src='' id="certimg" alt="" style="display: none; width: 220px; height: 150px;"
                                                    class="pointer" />
                                            </div>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td colspan="2">
                                            <div class="ckicon" id="btnSaveDiv" runat="server">
                                                <a id="SaveMachineInfo" parentdiv="machineInfo" href="javascript:void(0);">保存</a>
                                            </div>
                                        </td>
                                    </tr>
                                </table>
                            </td>
                        </tr>
                    </table>
                    <div class="clear">
                    </div>
                </div>
            </td>
            <td class="right_con">
                &nbsp;
            </td>
        </tr>
        <tr>
            <td class="con_m tt_left_bottom">
                &nbsp;
            </td>
            <td colspan="2" class="con_m">
                &nbsp;
            </td>
            <td class="tt_right_bottom">
                &nbsp;
            </td>
        </tr>
    </table>
    <input id="hdStatus" type="hidden" runat="server" />
    <input id="hdID" type="hidden" runat="server" />
</asp:Content>
